package com.jming.jike.dto.backend;

import com.jming.jike.common.ValidatorGroup.Insert;
import com.jming.jike.common.ValidatorGroup.Update;
import com.jming.jike.dto.BaseDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * @author jinming.zhang
 * @version 0.0.1
 * @date 2022/04/15
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class CategoryDTO extends BaseDTO {

    @ApiModelProperty(value = "菜品分类id")
    @NotNull(message = "分类id不能为空", groups = {Update.class})
    @Min(value = 1, message = "分类id最小为{value}", groups = {Update.class})
    private Long id;

    @ApiModelProperty(value = "1 菜品分类 2 套餐分类")
    @NotNull(message = "类型不能为空", groups = {Insert.class, Update.class})
    @Range(min = 1, max = 2, message = "类型不正确:{min}或{max}", groups = {Insert.class, Update.class})
    private Integer type;

    @ApiModelProperty(value = "分类名称")
    @NotBlank(message = "分类名称不能为空", groups = {Insert.class, Update.class})
    @Length(max = 30, message = "分类名称不能超过{max}个字符", groups = {Insert.class, Update.class})
    private String name;

    @ApiModelProperty(value = "顺序")
    @NotNull(message = "顺序不能为空", groups = {Insert.class, Update.class})
    @Min(value = 1, message = "顺序最小为{value}", groups = {Insert.class, Update.class})
    private Integer sort;

}
